<template>
  <div class="bgColor">
    <!-- 1.0 导航栏 -->
    <van-nav-bar
      title="我的跟帖"
      left-text="返回"
      left-arrow
      @click-left="$router.back()"
      fixed
      placeholder
    />
    <!-- 评论列表 -->
    <div class="list">
      <!-- 列表渲染 -->
      <div class="item" v-for="item in list" :key="item.id">
        <!-- 日期部分 -->
        <div class="date">
          <span>{{ item.create_date.split("T")[0] }}</span>
          <span>{{ item.create_date.split("T")[1].slice(0, 5) }}</span>
        </div>
        <div class="parent" v-if="item.parent">
          <p>
            <span>回复:</span><span>{{ item.parent.user.nickname }}</span>
          </p>
          <p>{{ item.parent.content }}</p>
        </div>
        <!-- 评论内容部分 -->
        <div class="content">
          {{ item.content }}
        </div>
        <!-- 文章链接部分  -->
        <div class="detail" @click="$router.push(`/detail/${item.post.id}`)">
          <p>{{ item.post.title }}</p>
          <i class="iconfont iconjiantou1"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getUserComment } from "@/api";
export default {
  data() {
    return {
      list: [],
    };
  },
  created() {
    getUserComment().then((res) => {
      //   console.log(res);
      this.list = res.data.data;
    });
  },
};
</script>

<style lang="less" scoped>
.bgColor {
  background-color: #f2f2f2;
}
.list {
  .item {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    .date {
      font-size: 13px;
      color: #888;
      span {
        margin-right: 5px;
      }
    }
    .parent {
      padding: 10px;
      background-color: #e4e4e4;
      margin: 10px 0;
    }
    .content {
      margin: 10px 0;
      color: #333;
    }

    .detail {
      font-size: 12px;
      color: #888;
      display: flex;
      align-items: center;
      height: 30px;
      p {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>